#!/bin/bash
###
# @Author: 以谁为师
# @Website: attacker.club
# @Date: 2020-08-26 09:17:33
# @LastEditTime: 2020-08-27 15:27:49
# @Description:
###

db_init() {
  pip3  install -i http://mirrors.aliyun.com/pypi/simple  --trusted-host mirrors.aliyun.com  -r requirements.txt
  python manage.py makemigrations
  python manage.py migrate
  # 初始化数据
  python init.py
  # 第一次初始化密码
}

# shellcheck disable=SC2120
replace_settings() {
  if [ $1x == "debug"x ]; then
    sed -i  's/DEBUG = False/DEBUG = True/'g  website/settings.py
    echo -e "Enable Debug ......"
  else
    sed -i  's/DEBUG = True/DEBUG = False/'g  website/settings.py
    echo -e "Disable Debug ......"
    # 关闭调试模式
  fi

}

run_server() {
  db_init
  replace_settings
  python manage.py runserver 0.0.0.0:8000
}

run_server # 启动服务
